package com.magnificent.atlantis.common.entity;

import com.magnificent.commons.db.datasource.ObjectEntity;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;

/**
 * User: Babanin
 * Date: 04.05.2009
 * Time: 20:25:18
 */
@Entity()
@Table(name = "event")
public class ServerMeeting extends ObjectEntity {
    private Date date;
    private String title;
    private String description;

    private boolean open;
    private boolean finished;

    private int moderatorId;

    private ArrayList<Integer> guestUsers;
    private ArrayList<Integer> invitedUsers;
    private ArrayList<Integer> acceptedByUsers;
    private ArrayList<Integer> canceledByUsers;
    private ArrayList<Integer> receiveInviteUsers;

    @Basic()
    @Column(name = "date")
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @Basic()
    @Column(name = "description")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Basic()
    @Column(name = "open")
    public boolean isOpen() {
        return open;
    }

    public void setOpen(boolean open) {
        this.open = open;
    }

    @Basic()
    @Column(name = "finished")
    public boolean isFinished() {
        return finished;
    }

    public void setFinished(boolean finished) {
        this.finished = finished;
    }

    @Basic()
    @Column(name = "title")
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Basic()
    @Column(name = "moderatorId")
    public int getModeratorId() {
        return moderatorId;
    }

    public void setModeratorId(int moderatorId) {
        this.moderatorId = moderatorId;
    }

    @Lob()
    public ArrayList<Integer> getInvitedUsers() {
        return invitedUsers;
    }

    public void setInvitedUsers(ArrayList<Integer> invitedUsers) {
        this.invitedUsers = invitedUsers;
    }

    @Lob()
    public ArrayList<Integer> getCanceledByUsers() {
        return canceledByUsers;
    }

    public void setCanceledByUsers(ArrayList<Integer> canceledByUsers) {
        this.canceledByUsers = canceledByUsers;
    }

    @Lob()
    public ArrayList<Integer> getGuestUsers() {
        return guestUsers;
    }

    public void setGuestUsers(ArrayList<Integer> guestUsers) {
        this.guestUsers = guestUsers;
    }

    @Lob()
    public ArrayList<Integer> getAcceptedByUsers() {
        return acceptedByUsers;
    }

    public void setAcceptedByUsers(ArrayList<Integer> acceptedByUsers) {
        this.acceptedByUsers = acceptedByUsers;
    }

    @Lob()
    public ArrayList<Integer> getReceiveInviteUsers() {
        return receiveInviteUsers;
    }

    public void setReceiveInviteUsers(ArrayList<Integer> receiveInviteUsers) {
        this.receiveInviteUsers = receiveInviteUsers;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ServerMeeting meeting = (ServerMeeting) o;

        if (date != null ? !date.equals(meeting.date) : meeting.date != null) return false;
        if (guestUsers != null ? !guestUsers.equals(meeting.guestUsers) : meeting.guestUsers != null) return false;
        if (invitedUsers != null ? !invitedUsers.equals(meeting.invitedUsers) : meeting.invitedUsers != null)
            return false;
        if (title != null ? !title.equals(meeting.title) : meeting.title != null) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = (date != null ? date.hashCode() : 0);
        result = 31 * result + (title != null ? title.hashCode() : 0);
        result = 31 * result + (invitedUsers != null ? invitedUsers.hashCode() : 0);
        result = 31 * result + (guestUsers != null ? guestUsers.hashCode() : 0);
        return result;
    }
}
